const express = require('express');

const app = express();
const fs = require('fs');
//获取客户端 ip 地址
app.use(function(request, response, next){
    response.setHeader('Access-Control-Allow-Origin', "*");
    response.setHeader('Access-Control-Allow-Headers', "*");
    response.setHeader('Access-Control-Allow-Methods', "*");
    next();
});

app.all('/server', (request, response) => {
    response.send('HELLO abc');
});

//delay 延时
app.all('/delay-server', (request, response) => {
    setTimeout(() => {
        response.send('HELLO abc');
    }, 3000)
});

app.head('*', (request, response) => {
    response.statusCode = 200;
    response.send('');
});

app.listen(80, () => {
    console.log('服务已经启动....');
});
